package com.crm.custservice;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.crm.common.Page;
import com.crm.custservice.po.CustService;
import com.crm.dao.CommonDAO;

public class CustServiceDAO extends CommonDAO implements ICustServiceDAO {
	public boolean updateCustServiceRefid(CustService custService){
		this.getSqlMapClientTemplate().update("CustService.updateCustServiceRefid", custService);
		return true;
	}

	public CustService addCustService(CustService custService) {
		this.getSqlMapClientTemplate().insert("CustService.insertCustService", custService);
		return custService;
	}
	public List getCustServList(CustService custService, HttpServletRequest request) {
		Page page = new Page();
		page.setPagesize(13);
		int currentPage = page.getCurrentPage(request);
		Integer count = (Integer) this.getSqlMapClientTemplate()
		.queryForObject("CustService.getCustServCount", custService);
		page.setRscount(count.intValue());
		
		int pagesize = page.getPagesize();
		System.out.println("currentPage="+currentPage);
		String pagetool = page.pagetool(request.getRequestURI()+ page.getParams(request));
		request.setAttribute("pagetool", pagetool);
		
		List list = this.getSqlMapClientTemplate().queryForList(
				"CustService.getCustServList", custService,
				(currentPage - 1) * pagesize, pagesize);
		return list;
	}
	public List getCustServListByEmployId(Integer id) {
		
		List list = this.getSqlMapClientTemplate().queryForList("CustService.getCustServListByEmployId", id);
		return list;
	}
	public CustService getCustServById(String id) {
		CustService map = (CustService)this.getSqlMapClientTemplate().queryForObject("CustService.getCustServById", id);
		return map;
	}	
}
